<template>
  <div class="represent-wrapper" v-if="data.img_show">
    <img src="@/assets/represent/rules.jpg" alt />
    <button class="btn" @click="buyGoods">立即购买</button>
    <div class="desc">
      <div class="left">
        <img :src="data.img_show" alt />
      </div>
      <div class="right">
        <p>{{ data.name }}</p>
        <p>
          <span class="price">¥{{ data.price }}</span>
          <span class="guige">这是规格</span>
        </p>
      </div>
    </div>
  </div>
</template>
<script>
import { getPresentGoods } from '@/api/represent'
const ERR_OK = 200
export default {
  data() {
    return {
      data: {}
    }
  },
  created() {
    this._getPresentGoods()
  },
  methods: {
    buyGoods() {
      this.$router.push({ path: '/payment', query: { type: 'represent' }})
    },
    _getPresentGoods() {
      getPresentGoods()
        .then(res => {
          if (res.data.code === ERR_OK) {
            console.log(res)
            this.data = res.data.data
          }
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
};
</script>
<style lang="less" scoped>
.represent-wrapper {
  position: relative;
  .btn {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 6.72rem;
    height: 1.52rem;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0rem 0rem 0rem 0rem rgba(183, 183, 183, 0.5);
    border-radius: 1rem;
    text-align: center;
    line-height: 1.52rem;
    font-size: 0.72rem;
    font-family: zihun58hao-chuangzhonghei;
    font-weight: 400;
    color: rgba(51, 51, 51, 1);
    top: 18.8rem;
  }
  .desc {
    width: 12.24rem;
    height: 4.86rem;
    padding: 0.8rem 0.32rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 21.75rem;
    display: flex;
    align-items: center;
    .left {
      width: 3.26rem;
      height: 3.26rem;
      background: rgba(179, 149, 117, 1);
      opacity: 0.52;
      border-radius: 0.1rem;
      margin-right: 0.52rem;
      overflow: hidden;
      img{
        width: 100%;
      }
    }
    .right {
      flex: 1;
      height: 100%;
      padding: 0.36rem 0;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      p {
        width: 100%;
        &:nth-child(1) {
          width: 7.3rem;
          font-size: 0.56rem;
          font-family: PingFang SC;
          font-weight: 500;
          color: rgba(102, 102, 102, 1);
          line-height: 0.76rem;
        }
        &:nth-child(2) {
          display: flex;
          justify-content: space-between;
          align-items: center;
          .price {
            font-size: 0.6rem;
            font-family: PingFang SC;
            font-weight: bold;
            color: rgba(102, 102, 102, 1);
            line-height: 0.64rem;
          }
          .guige {
            background: rgba(56, 44, 37, 1);
            border-radius: 0.38rem;
            font-size: 0.44rem;
            font-family: PingFang SC;
            font-weight: 400;
            color: rgba(255, 235, 216, 1);
            padding: 0.16rem 0.4rem;
            text-align: center;
            margin-right: 0.5rem;
          }
        }
      }
    }
  }
}
</style>